package org.reborn.engine.input.jinput

import org.reborn.engine.input._
import net.java.games.input.{Mouse => JIMouse, Component}

/**
 * A JInput implementation of a Mouse InputDevice
 */
class JInputMouse(val jInputMouse:JIMouse) extends Mouse {
  val deviceName = "JInput Mouse - " + jInputMouse.getName()
	
  val leftButton = new JIButton("Left Button", jInputMouse.getLeft)
  val rightButton = new JIButton("Right Button", jInputMouse.getRight)
  val middleButton = new JIButton("Middle Button", jInputMouse.getMiddle)
  
  val changeX = new JIPositionChange("Change X", jInputMouse.getX);
  val changeY = new JIPositionChange("Change Y", jInputMouse.getY);
  val changeScrollWheel = new JIPositionChange("Change Scroll Wheel", jInputMouse.getWheel);
  
  protected val components:List[JIComponent[_]] = 
	  List(leftButton, rightButton, middleButton, changeX, changeY, changeScrollWheel)
  
  def poll():Unit = {
	jInputMouse.poll
	for(component <- components){
	  component.updateComponentState
	}
  }
}

